package com.demo.sun.t_sensordata.Base;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

/**
 * Created by Sun on 2018/5/26.
 *  @version V1.0 <Fragment基类>
 */

public abstract class BaseFragment extends Fragment {
    protected  abstract int getLayoutId();
    protected abstract  void initView(View view, Bundle savedInstanceState);
    protected abstract  void initDatas();
    protected abstract  void doViews();
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        return inflater.inflate(getLayoutId(),null);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initView(view,savedInstanceState);
        initDatas();
        doViews();
    }

    public void showToast(Context context, String text){
        Toast.makeText(context,text, Toast.LENGTH_SHORT).show();
    }
    public void showLongToast(Context context, String text){
        Toast.makeText(context,text, Toast.LENGTH_SHORT).show();
    }

    public void loge(String tag,String msg){
        Log.e(tag,msg);
    }

}
